package com.tanhua.server.interceptor;

import com.tanhua.model.domain.User;

/**
 * @author : xyiaao
 * @createDate : 2022/3/16 20:08
 */
public class UserHolder {

    private static ThreadLocal<User> threadLocal = new ThreadLocal<>();

    public static void set(User user) {

        threadLocal.set(user);
    }

    public static User get() {

        return threadLocal.get();
    }

    public static Long getUserId() {

        return threadLocal.get().getId();
    }

    public static String getMobile() {

        return threadLocal.get().getMobile();
    }

    public static void remove() {

        threadLocal.remove();
    }

}
